const button1 = document.getElementById("buttonclick");
const tbody = document.querySelector("tbody");
button1.addEventListener('click', function () {
    axios({
        url: "http://localhost/selectServer",
        method: 'get',
        responseType: 'json'
    }).then(function (response) {
        tbody.innerHTML = "";
        var data = response.data;
        for (let i = 0; i < data.length; i++) {
            var tr = $("<tr></tr>");
            var parse = JSON.parse(data[i]);
            // 序号
            var td = "<td>" + (i + 1) + "</td>";
            tr.append(td);
            for (let key in parse) {
                var td = "<td>" + parse[key] + "</td>";
                if (parse[key]!=200&&key==="message"||(parse[key]!=='true'&&key==="upload")){
                    td = "<td style='color: red'>" + parse[key] + "</td>";
                }else if(parse[key]==200&&key==="message"||key==="upload"){
                    td = "<td style='color: green'>" + parse[key] + "</td>";
                }
                tr.append(td);
            }
            $("tbody").append(tr);
        }
    }).catch(function (error) {
        console.log(error);
    });
})
